<?php

defined('ACC') || exit('Access Denied');

class LoginModel extends Model{
	
	/* 获取用户密码 */
	public function check_user($username){
		$sql = 'select password from admin_user where username = ' . "'$username'";
		return $this->db->getRow($sql);
	}
	
	/* 修改上次登陆时间 */
	public function login_time($data, $username){
		return $this->db->autoExecute($data, 'admin_user', 'update', "username='$username'");
	}
	
	/* 获取用户权限id */
	public function check_role($username){
		$sql = "select role_id from admin_user where username = '$username'";
		return $this->db->getOne($sql);
	}
	
	/* 根据用户权限id,获取用户所有权限 */
	public function get_auth_list($role_id){
		$sql = "select auth_list from role where role_id = $role_id";
		return $this->db->getRow($sql);
	}
	
	/* 根据用户名获取用户权限id */
	public function get_role_id($username){
		$sql = 'select role_id from admin_user where username = ' . "'$username'";
		return $this->db->getOne($sql);
	}
	
}


?>